﻿
var path = "http://" + location.host + "/SSTA/unit/agent/";

var total=0;
var standard = "1";
var searchkeyword = "";
var unitcode = "";


function getNewEnergyExpertList(energyclass){
     if (energyclass=="7") 
         var url = path + "getNewEnergyExpertList.jsp?keyword=ChannelShow='1'&energyclass='"+ energyclass +"'&num=8";
     else    
         var url = path + "getNewEnergyExpertList.jsp?keyword=NewEnergyClass1='" + energyclass + "'  or NewEnergyClass2='" + energyclass + "'&energyclass='"+ energyclass +"'&num=8";
     XmlHttpPool.GetRemoteData(url, showNewEnergyExpertList);	
    
}

function replace_a(str,a,b){
	while(str.indexOf(a)!=-1){
			str=str.replace(a,b);
	}
	return str;
}

function showUnitResult(data) {

  	pagecap=5;
	var str2 = "";
	var str3 = "";
	
	var total = 0;
	var searchresult = "";
	
	var data = eval("("+data+")");
	  
	  searchresult = "";
	  
	  if(data!=null){
		  for(i = 0; i<data.length; i++) {
				
				if(i==0){
					total = data[i]['total'];
				}
		        var unitid = trim(data[i]['unitid']);
		        var item_9 = trim(data[i]['item_9']);
		        var unitintro = "";
		        if(data[i]['unitintro']!=null){
		        	unitintro = trim(data[i]['unitintro']);
		        	
		        	unitintro = replace_a(unitintro,"-n-n-n","")
		        	
		        	unitintro = (unitintro).substr(0,125)+"......";
		        }
		        
		        
		        var photo = trim(data[i]['unitid']);
		        
		        searchresult+="<div id=\"searchlist_left_kjcg\">";
		        searchresult+="<ul><li><span>机构名称：</span>";
		        
		        searchresult += "<a  style=\"color:#0F49A8;\" href = '/SSTA/unit/info.jsp?unitid=";
		        searchresult += unitid;
		        searchresult += "&title=" + item_9;
		        searchresult += "' target=\"_blank\">";
		        searchresult += item_9;
		        searchresult += "</a>";
		        
		        searchresult+="</li><li style=\"width:100%;\"><span>机构介绍：</span>";
		        searchresult+=unitintro;
		        searchresult+="</li></ul>";
		        
		        
		        searchresult+="<div id=\"morebotton_kjcg\">";
		         
		         
		        searchresult += "<a  style=\"color:#0F49A8;\" href = '/SSTA/unit/info.jsp?unitid=";
		        searchresult += unitid;
		        searchresult += "&title=" + item_9;
		        searchresult += "' target=\"_blank\">";
		        
		        searchresult+="<img src=\"../common/images/search/botton4.gif\" border=\"0\" /></a></div>";
		        searchresult+="</div><div id=\"clearboth\"></div>";
		        
		  }
	  
	  }
	  
	  
	  
      
	  totalpage = Math.ceil(total / pagecap);
	  
	  //alert("total:"+total+"    pagecap:"+pagecap+" cCount:"+cCount+" totalpage:"+totalpage); 
	  
	  str2+="<div style=\"height:20px;\"></div>";
	  str2 += "<div  style=\"margin-right:5px;cursor:hand;\" id = 'mylink'>" + setPage(cCount);    
	  str2 += "</div>";
         
       //    str3 = "<div style=\"margin-right:5px;margin-top:-10px;cursor:hand;\" id = 'mylink1'>" + "总页数："+ totalpage +"　"+setPage(cCount);    
	//   str3 += "</div>";
	
	  if (document.getElementById("blue_title") !=null){
             if (topicname != "")                 	                 	
             	document.getElementById("blue_title").innerHTML = "<div class=\"blue_title_right\">您的搜索条件：<font color=\"#0F49A8\">"+topicname+"</font>　　我们为您找到：<font color=\"#0F49A8\">"+total+"</font> 家单位</div>";                                
             else
                document.getElementById("blue_title").innerHTML = "<div class=\"blue_title_right\">共搜索到：<font color=\"#0F49A8\">" + total + "</font>条项目</div>";                        
	  }
      
      
      //alert(searchresult);
      
      
      if(document.getElementById("showUnitResult") !=null)   {
			document.getElementById("progressbar").style.display='none';  
			document.getElementById("showUnitResult").innerHTML =  searchresult + str2; 		
	  }
      
}



function getNewEnergyList(energyclass){
     //if (energyclass=="7") 
     //    var url = path + "getNewEnergyList.jsp?keyword=ChannelShow='1'&energyclass='"+ energyclass +"'";
    // else    
          url = path + "getNewEnergyList.jsp?keyword=NewEnergyClass1='" + energyclass + "'  or NewEnergyClass2='" + energyclass + "'&energyclass='"+ energyclass +"'&num=8&sorttype=";
          LoadXml_new();
                var searchresult = "";
                searchresult = "<div class=\"index_list\" >";
	        searchresult += "<ul>"; 
                var len = nodelist.length;
                for(i = 0; i < len; i++) {
                       searchresult += "<li>";
	               searchresult += "<a href = '/SSTA/unit/info.jsp?unitid=";
	               var unitid=getNodeValue(i,"UnitID");   	                  
	               var item_9=trim(getNodeValue(i,"Item_9"));   	                  

	               searchresult += unitid;
	               searchresult += "&title=" +item_9;
	               searchresult += "' target=\"_blank\"><img src=\"/SSTA/achieve/image/point_blue.gif\" border=0/>　";
	               if (item_9.length>18)
	                        searchresult += item_9.substring(0,17)+"...";
                             else                                
	               		searchresult += item_9;
	               searchresult += "</a>";
	               searchresult += "</li>";
                }
                searchresult += "</ul>";
	        searchresult += "</div>";                 
                var energyclass="";
                if (browse=="ie"){
                	if(xml.documentElement.selectSingleNode("//energyclass") != null) 
                  		energyclass = xml.documentElement.selectSingleNode("//energyclass").text;                	                	
                }
                
                if (browse=="ff") {
                	if(xml.getElementsByTagName("energyclass")[0].childNodes[0].nodeValue != "null")
                		energyclass =xml.getElementsByTagName("energyclass")[0].childNodes[0].nodeValue;
        	}
        	
                 switch (energyclass) {     
                   case "\'1\'":
                      document.getElementById("sun").innerHTML = searchresult;  
                      break; 
                   case "\'2\'": 
                      document.getElementById("wind").innerHTML = searchresult;  
                      break;
                   case "\'3\'": 
                      document.getElementById("living").innerHTML = searchresult;  
                      break;
                   case "\'4\'": 
                      document.getElementById("heat").innerHTML = searchresult;  
                      break;
                   case "\'5\'": 
                      document.getElementById("atom").innerHTML = searchresult;  
                      break;
                   case "\'6\'": 
                      document.getElementById("other").innerHTML = searchresult;  
                      break;
                   

                 }
              
  
}


function changePage(no) {
        
    url = path + "doSearch.jsp?keyword=" + searchkeyword;   
    
	var rd = total - no * pagecap;
	if(rd > pagecap || no == 1) {
	    rd = pagecap;
	}
	else if(rd > 0 && rd < pagecap) {
	    rd = pagecap;
	}
	else {
	   // rd = pagecap - (no * pagecap - total);
	    rd = pagecap ;
	}	    
	url += "&no="+ no + "&count=" + rd.toString();    
    //showUnitResult();
    XmlHttpPool.GetRemoteData(url, showUnitResult); 
}


function showUnitInfo(data) {
	   var data = eval("("+data+")");
	   var str = "";
       if(data.length == 0) {
			return;
	   }
	   
	   var item_9 = data['item_9'];
	   var unitcode = data['unitid'];
	   
	   
	   document.getElementById("int_show_con_title").innerHTML = item_9;
	   
	   document.getElementById("infotitle").value = item_9;
	   
	   
        str = "<div class=\"blank10\"></div>";
        //str += "<div class=\"title\">"+item_9 +"</div>";
        str += "<div class=\"blank10\"></div>";
	    str += "<table class=\"table_info\" cellspacing=\"0\"  align=\"center\" border=\"0\">";
	    
          
            
        str +="<tr><td width=\"15%\">【地  址】</td>";
        var Item_37 = data['item_37'];
        
        
		if (Item_37!=null){
			str +="<td width=\"40%\">"  + Item_37 +"</td>";
		}
		else{
			str +="<td width=\"40%\">&nbsp;</td>";
    	}			
	    
	    str +="<td width=\"15%\" >【邮  编】</td>";
	    var Item_38 = data['item_38'];
		if (Item_38 != null){
			str +="<td width=\"20%\">"  + Item_38 +"</td></tr>";
		}else{
			str +="<td width=\"20%\">&nbsp;</td></tr>";
	    }

        str +="<tr><td width=\"15%\">【电  话】</td>";
        var Item_39 = data['item_39'];
     	if (Item_39 != null){
			str +="<td>"  + Item_39 +"</td>";
		}else{
			str +="<td>&nbsp;</td>";
		}
		
	     str +="<td width=\"15%\">【传  真】</td>";
	     var Item_40 = data['item_40'];
		 if (Item_40!=null){
			str +="<td width=\"25%\">"  + Item_40 +"</td></tr>";
		 }
		 else{
			str +="<td width=\"25%\">&nbsp;</td></tr>";
		 }
   	 		
         str +="<tr><td colspan=\"4\" valign=\"top\">【单位简介】</td></tr>";
         var UnitIntro = data['unitintro'];
		 if(UnitIntro != null){
			UnitIntro = replace_a(UnitIntro,"-n-n-n-n-n-n","<br/>");
     		UnitIntro = replace_a(UnitIntro,"-n-n-n", "<br/>");
			str +="<tr><td colspan=\"4\">&nbsp;&nbsp;&nbsp;&nbsp;"  + UnitIntro +"</td></tr>";
		 }
		 else{
			str +="<tr><td colspan=\"4\">&nbsp;</td></tr>";
		 }
		 
         str += "</table>";
           
	     if(document.getElementById("showUnitInfo") !=null){
            document.getElementById("progressbar").style.display='none';  
	 		document.getElementById("showUnitInfo").innerHTML = str;
	     }
	  
}


/*function showUnitIntro() {
	
 	var url = path + "getUnitInfo.jsp?unitid=" + unitcode;
        var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp.open("GET", url, false);
        xmlhttp.send(null);
	var xml = new ActiveXObject("Microsoft.XMLDOM");
	xml.loadXML(xmlhttp.responseText);		
	resultDom.XMLDocument.loadXML(xmlhttp.responseText);
	            	  	   
    	var str_intro = "<div class=\"title\">单位简介</div>";
   	var tempobj = null;

		if(xml.documentElement != null) {
			var nodelist = xml.documentElement.selectNodes("//record");					
			tempobj = nodelist.item(0).selectSingleNode(".//UnitIntro");		
			if(tempobj != null && tempobj.text != "null") {
				str_intro += "<div class=\"blank10\"></div><div class=\"unitintro\">&nbsp;&nbsp;&nbsp;&nbsp;" + tempobj.text +"</div>";
			}
		}
	
	tempobj = null;
	document.all["unitintro"].innerHTML = str_intro;
}*/



function showTopKjcg() {

        LoadXml_new();
	var str = "";
       
	
	    var len = nodelist.length;
            str += "<div class=\"blank5\"></div>";
 	    str += "<table class=\"table_info2\" border=\"0\">";
	    for(i = 0; i < len; i++) {	           	              
	               str += "<tr><td>";
	               str += "<img src=\"/SSTA/achieve/image/point_blue.gif\" border=0/>　<a href = '/SSTA/achieve/info.jsp?kjcgid=";
	               var KjcgID = getNodeValue(i,"KjcgID");
	               var Kjcg_Item_3 = trim(getNodeValue(i,"Kjcg_Item_3"));
	               str += KjcgID;
	               str += "&title=" + Kjcg_Item_3;
	               str += "' target=\"_blank\">";
	               if (Kjcg_Item_3.length>18)
	               		str += Kjcg_Item_3.substring(0,17)+"...";
	               else
	               		str += Kjcg_Item_3;

	               str += "</td>";
	               str += "</tr>";
                                                                      
             }

	      str += "</table>";	
       
      if (document.getElementById("showTopKjcg") !=null){
               
		 document.getElementById("showTopKjcg").innerHTML = str;
	    }	  

}






